import { request } from '@umijs/max';

/** 分页查询数据字典类型 GET /system/dict/type/page/list */
export async function getDictTypeListByPage(params: API.QueryDictTypePageParams) {
  return request<API.QueryPageResp<API.DictType>>('/system/dict/type/page/list', {
    method: 'GET',
    params,
  });
}

/** 查询数据字典类型列表 GET /system/dict/type/list */
export async function getDictTypeList() {
  return request<API.Resp<API.DictType[]>>('/system/dict/type/list', {
    method: 'GET',
  });
}

/** 新增数据字典类型 POST /system/dict/type/add */
export async function addDictType(params: API.DictType) {
  return request<API.Resp>('/system/dict/type/add', {
    method: 'POST',
    data: params,
  });
}

/** 更新数据字典类型 POST /system/dict/type/update */
export async function updateDictType(params: API.DictType) {
  return request<API.Resp>('/system/dict/type/update', {
    method: 'POST',
    data: params,
  });
}

/** 通过ID查询单条数据字典类型 GET /system/dict/type/get/{id} */
export async function getDictTypeById(id: React.Key) {
  return request<API.Resp<API.DictType>>(`/system/dict/type/get/${id}`, {
    method: 'GET',
  });
}

/** 通过ID删除单条数据字典类型 POST /system/dict/type/delete */
export async function deleteDictTypeById(id: React.Key) {
  return request<API.Resp>(`/system/dict/type/delete`, {
    method: 'POST',
    params: {
      id,
    },
  });
}

/** 批量删除数据字典类型 POST /system/dict/type/deletes */
export async function deleteDictTypesByIdList(idList: React.Key[]) {
  return request<API.Resp>(`/system/dict/type/deletes`, {
    method: 'POST',
    data: idList,
  });
}

/** 查询字典类型下拉框列表 GET /system/dict/type/getDictTypeSelect */
export async function getDictTypeSelect() {
  return request<API.Resp<API.DictTypeSelect[]>>(`/system/dict/type/getDictTypeSelect`, {
    method: 'GET',
  });
}
